package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	file, error := os.Open("./1.txt")
	if error != nil {
		fmt.Printf("打开文件出错！", error)
	}
	defer file.Close()

	reader := bufio.NewReader(file)
	for {
		line, err := reader.ReadString(' ')
		if err == io.EOF {
			if len(line) != 0 {
				fmt.Println(line)
			}
			fmt.Println("文件读完了！")
			return

		}
		if err != nil {
			fmt.Printf("打开读取出错！", err)
			break
		}
		fmt.Println(line)
	}
}
